package pt.iscte.pcd.banquet;

import java.util.Random;

public class Cook extends Thread {

	private static final int MAX_PRODUCE_TIME = 1000;
	private static final int N_BOARS = 10;
	private Table table;
	private int n = 0;

	public Cook(Table table) {
		this.table = table;		
	}

	@Override
	public void run() {
		Random gen = new Random();
		while (n != N_BOARS) { // (!interrupted()) {
			Boar j = new Boar(this, n++);
			table.put(j);
			System.out.println("Produzido: " + j);
			try {
				sleep(gen.nextInt(MAX_PRODUCE_TIME));
			} catch (InterruptedException e) {
				// interrupted();
			}
		}
		
	}
	
//	public String toString() {
//		return super.toString();
//	}

	
}
